package com.tvb.dao;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;

public class BaseDao<T> {
	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;
	
	@PersistenceContext  
	private EntityManager em;

	public void save(T t){
		em.persist(t);
	}
	
	public T selectOne(String statement) {
		return sqlSessionTemplate.selectOne(statement);
	}

	public T selectOne(String statement, Object paramenter) {
		return sqlSessionTemplate.selectOne(statement, paramenter);
	}

	public List<T> selectList(String statement) {
		return sqlSessionTemplate.selectList(statement);
	}

	public List<T> selectList(String statement, Object paramenter) {
		return sqlSessionTemplate.selectList(statement, paramenter);
	}
}
